package homework03;

import java.util.Scanner;
public class userSystem{
    private user[] users = new user[100];
    private int usercount = 0;
    public void register(){
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入注册用户名:");
        String username = scanner.nextLine();
        System.out.println("请输入请输入注册用户密码:");
        String userpassword = scanner.nextLine();

        for (int i = 0; i < usercount; i++) {
            if (users[i].getUsername().equals(username)) {
                System.out.println("用户已经存在,注册失败！");
                return;
            }
        }

        users[usercount++] = new user(username,userpassword);
        System.out.println("注册成功");
    }

    public void login() {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入注册用户名:");
        String username = scanner.nextLine();
        System.out.println("请输入请输入注册用户密码:");
        String userpassword = scanner.nextLine();

        for (int i = 0; i < usercount; i++) {
            if (users[i].getUsername().equals(username) && users[i].getUserpassword().equals(userpassword)) {
                System.out.println("登陆成功!");
                return;
            }
        }
        System.out.println("用户名或密码错误，登录失败！");
    }

}
